/**
 * 登录模块，提供登录相关业务功能
 * 
 * @Date: 2015-6-16
 * @author: Jackson wang
 * @version: 1.0
 * @since: 1.0
 */
define(["jquery", "tabServ","highchart", "ajaxServ",  "bizProto","sysmanMain","medicalIndicate","satisfactionIndicate","dutiesIndicate","supplyIndicate",
			"highchartTheme","valueUtil","btnServ","formServ","dutiesInquiryInfo","medicalInfo","satisfactionInfo","supplyInquiry"],
		function($,tabServ,  highchart, ajaxServ, bizProto,sysmanMain,medicalIndicate,satisfactionIndicate,dutiesIndicate,supplyIndicate,
			highchartTheme,valueUtil,btnServ,formServ,dutiesInquiryInfo,medicalInfo,satisfactionInfo,supplyInquiry) {

			'use strict';

			var _bizProto,_buttonConfig,
				//锚记datagrid目标元素
				$dg,
				//初始化后的datagrid dom对象
				$grid,
				//编辑弹窗对象及弹窗按钮对象
				$edit_window,window_btn,
				//设置密码弹窗对象及按钮对象
				$password_window,password_btn,
				//业务表单对象
				$form,
				//部门选择框字段
				_defaultConfig ={},
				_medicalPricePanel,
				_medicalPathwayPanel,
				_medicalUsePanel,
				_medicalCheckPanel,
				_medicalMedicalMangerPanel,
				
				chartConfig ={
					chart: {
			            plotBackgroundColor: null,
			            plotBorderWidth: null,
			            plotShadow: false
			        },
			        credits:{
			        	enabled:false
			        },
			        title: {
			            text: false
			        },
			        tooltip: {
			            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
			        },
			        legend:{
			        	labelFormat:'{name}: <b>{y}</b>次 , <b>{percentage:.1f}%</b>'			        	
			        },
			        plotOptions: {
			            pie: {
			                allowPointSelect: true,
			                cursor: 'pointer',
			                dataLabels: {
			                    enabled: false,
			                    distance:-20,
			                    format: '<b>{point.name}</b>:{point.y}件'
			                },
			                style: {
		                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
		                    },
		                    showInLegend: false
			            }
			        }
				},
				
				_colors = ["#ff0033","#99ccff",  "#99cc00"],
				//url define
				dutiesStatisticAllUrl = '/honest/query/getStaticInfoAll.action',
				
				//职能监控数据指标url
				dutiesIndicateUrl = '/dutiesStatistic/query/getListDomain.action',
				
				//医疗服务全院监控指标url
				baseInfoAllUrl = '/basePatientInfo/query/getDeptListDomain.action',

				//医疗服务药品监控指标
				medicalIndicateAllUrl = '/basePatientInfo/query/getIndicateListDomain.action',

				//医疗服务临床路径监控指标
				medicalPathwayPart = '/basePatientInfo/query/getIndicateListDomain.action',	
				//医疗服务价格监控指标
				medicalPricePart = '/basePatientInfo/query/getIndicateListDomain.action',	
				//医疗服务药品监控指标
				medicalUsePart = '/basePatientInfo/query/getIndicateListDomain.action',	
				//医疗服务药品监控指标
				medicalCheckPart = '/basePatientInfo/query/getIndicateListDomain.action',
				//医疗服务药品监控指标
				medicalMedicalMangerPart = '/drugCounting/query/popPage.action',
				
				//医疗服务大型阳性率监控指标
				medicalIndicateLargePositiveUrl = '/largePositive/query/getLargePositiveListDomain.action',				
	
				//满意度监控指标url
				baseSatisfactionInfoUrl = '/satisfactionBaseinfo/query/getListDomain.action',
				
				//供应商监控指标url
				baseSupplyInfoUrl = '/baseSupplyInfo/query/getListSupplyInfo.action',
				
				rootid = 'panel-chart-all'

			var public_method = {
				
				
				init:function(_options){
					
				    
				    var _colors1 = Highcharts.getOptions().colors
				    var _startDate = $('#' +rootid+' #inquiry_start')
						
					var _endDate = $('#' +rootid+' #inquiry_end')
					if(_startDate.length>0){
						var curDate = new Date();
						
						var _tmp = valueUtil.getDateValue({source:curDate,format:'yyyy-MM-dd'})
						$(_endDate).datebox('setValue',_tmp);						
						
						
						curDate.setDate(1);
						
						_tmp = valueUtil.getDateValue({source:curDate,format:'yyyy-MM-dd'})
						$(_startDate).datebox('setValue',_tmp);
					}
					
					//替换默认颜色
					if(_options.color){
						_colors = _options.color
					}
					private_method.init(_options);
				}
				
			}

			var private_method = {
				init : function(_options) {
					if(window.console)
						console.info('chart all modules gets ready and been loaded.');
					
					$.extend(_defaultConfig,_options)
					_bizProto = new bizProto(_options)
					
					_buttonConfig={					
						"执行查询":private_method.initElement
					}
					private_method.bindBtnEvent()
					private_method.initElement(_bizProto.pageDoc)
					
					//关闭加载条
					$.messager.progress('close');
				},				
				bindBtnEvent:function(){
					
					var	btn = $('#' +rootid +' a.function-btn')
					
					// 绑定按钮事件
					
					//判断按钮是否存在
					if(btn.length>0){
						$(btn).unbind('click');
						$(btn).bind('click', private_method.function_btn_listenner)	
					}
					
					//医疗服务指标窗口
					var links = $('#' + rootid + ' a.medical-indicate')
					if(links.length>0){
						$(links).unbind('click');
						$(links).bind('click', private_method.openMedicalPage)	
					}
					
					var medicalPathwayPanelBut = $('#' + rootid + ' .medical-panel-but .pathway-but')
					if(medicalPathwayPanelBut.length>0){
						$(medicalPathwayPanelBut).unbind('click');
						$(medicalPathwayPanelBut).bind('click', private_method.medicalPathwayPanel)	
					}
					
					var medicalPricePanelBut = $('#' + rootid + ' .medical-panel-but .price-but')
					if(medicalPricePanelBut.length>0){
						$(medicalPricePanelBut).unbind('click');
						$(medicalPricePanelBut).bind('click', private_method.medicalPricePanel)	
					}
					
					var medicalUsePanelBut = $('#' + rootid + ' .medical-panel-but .use-but')
					if(medicalUsePanelBut.length>0){
						$(medicalUsePanelBut).unbind('click');
						$(medicalUsePanelBut).bind('click', private_method.medicalUsePanel)	
					}
					
					var medicalCheckPanelBut = $('#' + rootid + ' .medical-panel-but .check-but')
					if(medicalCheckPanelBut.length>0){
						$(medicalCheckPanelBut).unbind('click');
						$(medicalCheckPanelBut).bind('click', private_method.medicalCheckPanel)	
					}

					var medicalMedicalMangerPanelBut = $('#' + rootid + ' .medical-panel-but .medicalManger-but')
					if(medicalMedicalMangerPanelBut.length>0){
						$(medicalMedicalMangerPanelBut).unbind('click');
						$(medicalMedicalMangerPanelBut).bind('click', private_method.medicalMedicalMangerPanel)	
					}
					
					//打开满意度指标窗口
					var sl = $('#' + rootid + ' a.satisfied-indicate')
					if(sl.length>0){
						$(sl).unbind('click');
						$(sl).bind('click', private_method.openSatisfactionPage)	
					}
					
					//打开供应商指标窗口
					var sul = $('#' + rootid + ' a.supply-indicate')
					if(sul.length>0){
						$(sul).unbind('click');
						$(sul).bind('click', private_method.openSupplyPage)	
					}
					
					
				},
				
				
				/**
				 * 数字链接点击事件
				 */
				function_links_listenner:function(e){
					//根据点击类型调用不同弹出页面
				},
				// 功能按钮监听函数
				function_btn_listenner : function(e) {
		
					btnServ.applyButton({buttonEvt:e,buttonConfig:_buttonConfig})
		
				},
				
				getIndicateDate:function(){
					var _data = private_method.getDateValue()
					var mym
					if(_data.inquiry_start){
						var year = _data.inquiry_start.substring(0,4);
						var month = parseInt(_data.inquiry_start.substring(5,7));					
						mym=year + '-' + month;
					}else{
						mym = _data.monitor_year_month;
					}
					return mym
				},
				/**
				 * 打开医疗服务点击数据窗口
				 */
				openMedicalPage:function(e){
					
					var mym = private_method.getIndicateDate();
					
					medicalIndicate.openPage({evt:e,yearAndMonth:mym})
				},
				
				/**
				 * 打开满意度点击数据窗口
				 */
				openSatisfactionPage:function(e){
					var mym = private_method.getIndicateDate();
					satisfactionIndicate.openPage({evt:e,yearAndMonth:mym})
				},
				
				/**
				 * 打开供应商点击数据窗口
				 */
				openSupplyPage:function(e){
					var mym = private_method.getIndicateDate();
					supplyIndicate.openPage({evt:e,yearAndMonth:mym})
				},
				
				/**
				 * 打开供应商点击数据窗口
				 */
				openDutiesPage:function(e){
					var mym = private_method.getIndicateDate();
					dutiesIndicate.openPage({evt:e,yearAndMonth:mym})
				},
				//初始化元素
				initElement:function(doc){
					
					var _data = private_method.getDateValue()					
					_medicalPricePanel = null;
					_medicalMedicalMangerPanel = null;
					_medicalPathwayPanel = null;
					_medicalUsePanel = null;
					_medicalCheckPanel = null;
					ajaxServ.runAjax({
						url:_bizProto.rootPath + dutiesStatisticAllUrl,
						data:{condition:_data},
						callback:private_method.initChart					
					})
					
					//查询所有业务数据
					if(_data.inquiry_start){
						var year = _data.inquiry_start.substring(0,4);
						var month = parseInt(_data.inquiry_start.substring(5,7))
						
						_data.monitor_year_month=year + '-' + month;
					}
					
					//查询职能指标信息信息
					ajaxServ.runAjax({
						url:_bizProto.rootPath + dutiesIndicateUrl,
						data:{condition:_data},
						callback:function(data){
							if(data &&　data.rows.length>0){
								var _c = data.rows.length<10 ? data.rows.length:10;
								
								var _el = $('#' + rootid + ' #duties-indicate-info')
								
								if(window.console){
									console.log(' duties out of date show ......')
								}
								//超限业务数量
								var _oc = 0;
								for(var i =0;i<_c;i++){
									var _d = data.rows[i]
									_oc +=_d.sumary_matter
								}
								_el.empty();
								
								
								var _dutiesNum 
								if(_oc<=0){
									_dutiesNum = '<span>' + _oc + '</span> '
								}else{
									_dutiesNum = '<span><font color="red">' + _oc + '</font></span> '
								}
								var _dutiesInfo = '<span class="panel-title"> 业务总量</span>' +
												  '<div class="t-list">超限业务数量：<a href="#" class="duties-num duties-indicate" indicate="duties-num">'+_dutiesNum+
												  '</a><span> 件</span></div>';
								
								_el.append(_dutiesInfo);
								
								for(var i =0;i<_c;i++){
									var _d = data.rows[i]
									
									
									if(_d && _d.sumary_matter!=null){
										var _ti = 'duties-dept' + (i+1) + '-num ';
										var _html = '<div class="t-list">'+_d.dept_name +': '+ '<a href="#" class="' + _ti 
													+'important-num duties-indicate" indicate="' + _ti +'"><span><font color="red">'+_d.sumary_matter +
													'</font></span> </a> <span> 件</span></div>'
//										if(window.console){
//											console.log(_html)
//										}
										_el.append(_html);
									}
									
									
								}
								
								//打开职能指标窗口
								var dl = $('#' + rootid + ' a.duties-indicate')
								if(dl.length>0){
									$(dl).unbind('click');
									$(dl).bind('click', private_method.openDutiesPage)	
								}
																
							}
							
						}
					})
					
					//查询基本业务信息
					ajaxServ.runAjax({
						url:_bizProto.rootPath + baseInfoAllUrl,
						data:{condition:_data},
						callback:function(data){
							if(data &&　data.rows.length>0){
								$.each(data.rows,function(index,row){
									if(row){
										if(row.patient_type==1){
											$('#' + rootid + ' a.outpatient-num span').html(row.outpatient_num)
											$('#' + rootid + ' a.outpatient_count_money span').html(row.outpatient_count_money)
										}else{
											$('#' + rootid + ' a.inpatient-out-num span').html(row.inpatient_out_num)
											$('#' + rootid + ' a.inpatient_num span').html(row.inpatient_num)											
											$('#' + rootid + ' a.inpatient_out_count_money span').html(row.inpatient_out_count_money)								
										}
									}
								})								
							}
							
						}
					})
					
					private_method.medicalUsePanel();
					
					
					//查询满意度信息
					ajaxServ.runAjax({
						url:_bizProto.rootPath + baseSatisfactionInfoUrl,
						data:{condition:_data},
						callback:function(data){
							if(data &&　data.rows.length==1){
								var row = data.rows[0];
								if(row){
									var _m = row.myl
									if(_m){
										_m = parseFloat(_m).toFixed(2);
										
										if(_m >= 90){
											_m ='<font color="green">'+ _m + '</font>'
										}else{
											_m ='<font color="red">'+ _m + '</font>'
										}
									}
									$('#' + rootid + ' span.satisfied-percent').html(_m)
									
									$('#' + rootid + ' a.satisfied-window-num span').html(row.satisfied_window_num)
									$('#' + rootid + ' a.outinpatient-problem-num span').html(row.outinpatient_problem_num)										
									$('#' + rootid + ' a.inpatient-dept-num span').html(row.inpatient_dept_num)
									$('#' + rootid + ' a.inpatient-problem-num span').html(row.inpatient_problem_num)
									
									$('#' + rootid + ' a.window-percent span').html(row.window_percent)
									$('#' + rootid + ' a.outinpatient-problem-percent span').html(row.outinpatient_problem_percent)										
									$('#' + rootid + ' a.inpatient-dept-percent span').html(row.inpatient_dept_percent)
									$('#' + rootid + ' a.inpatient-problem-percent span').html(row.inpatient_problem_percent)									
								}															
							}
							
						}
					})
					
					//查询供应商业务、指标信息
					ajaxServ.runAjax({
						url:_bizProto.rootPath + baseSupplyInfoUrl,
						data:{condition:_data},
						callback:function(data){
							if(data&&data.rows.length==1){
								var row = data.rows[0];
								if(row.supply_num){
									   $('#' + rootid + ' a.supply-num span').html(row.supply_num)
								   }
								if(row.apply_supply_audit_num){
									   $('#' + rootid + ' a.supply-audit-num span').html(row.apply_supply_audit_num)
								   }
								if(row.pass_supply_audit_num){
									   $('#' + rootid + ' a.supply-permit-num span').html(row.pass_supply_audit_num)
								} 
								if(row.lack_supply_baseinfo_num){
									   $('#' + rootid + ' a.supply-base-info span').html(row.lack_supply_baseinfo_num)
								   }
								if(row.lack_supply_archive_num){
									   $('#' + rootid + ' a.supply-archive span').html(row.lack_supply_archive_num)
								}
								if(row.supply_badinfo_num){
									   $('#' + rootid + ' a.supply-bad-info span').html(row.supply_badinfo_num)
								  
							  }
								
																	
						  }
							
					   }
				   })
					
				},
				
				medicalPricePanelHtml:function(){
					var tepHtml = "<span><div class=\"t-list\">超限处方数: <a href=\"#\" class=\"overlay-prescribe medical-indicate\" indicate=\"overlay-prescribe\"><span>0</span> </a> </div>	</span>" +
							"<div class=\"t-list\">大额住院费用: <a href=\"#\" class=\"large-cost medical-indicate\" indicate=\"large-cost\"><span>0</span> </a> 人</div>" +
							"<div class=\"t-list\">单病种费用: <a href=\"#\" class=\"medical_single_entity_fee medical-indicate\" indicate=\"medical_single_entity_fee\"><span>0</span> </a> 人</div>"
					$('#' + rootid + ' .medical-panel-change').html(tepHtml)
				},
				
				medicalPricePanel:function(){
					var _panel_change = $('#' + rootid + ' .medical-panel-change')
					_panel_change.empty()
					if(_medicalPricePanel){
						
						_panel_change.html(_medicalPricePanel)
						private_method.bindBtnEvent()
					}
					else{
						var _data = private_method.getDateValue()
						private_method.medicalPricePanelHtml()
						ajaxServ.runAjax({
							url:_bizProto.rootPath + medicalPricePart,
							data:{condition:_data},
							callback:function(data){
								if(data){
									if(data.overlay_prescribe && data.overlay_prescribe.rows[0]){
										var row = data.overlay_prescribe.rows[0]
										if(row){
											var cnt = 0
											if(row.drug_price_overlay){
												cnt += parseInt(row.drug_date_overlay)
											}
											
											if(row.drug_type_overlay){
												cnt += parseInt(row.drug_type_overlay)
											}
											
											if(row.drug_date_overlay){
												cnt += parseInt(row.drug_date_overlay)
											}
											
											if(cnt > 0){
												cnt = '<font color="red">' + cnt + '</font>'
											}else{
												cnt = '<font color="green">' + cnt + '</font>'
											}
											$('#' + rootid + ' a.overlay-prescribe span').html(cnt)
											//$('#' + rootid + ' a.overlay-prescribe span').html('0')
										}
									}
									if(data.large_cost && data.large_cost.rows[0]){
										var row = data.large_cost.rows[0]
										if(row && row.parentid_all){
											var cnt = row.parentid_all
											if(cnt > 0){
												cnt = '<font color="red">' + cnt + '</font>'
											}else{
												cnt = '<font color="green">' + cnt + '</font>'
											}
											$('#' + rootid + ' a.large-cost span').html(cnt)
										}
									}
									if(data.medical_single_entity_fee && data.medical_single_entity_fee.rows[0]){
										var row = data.medical_single_entity_fee.rows[0]
										if(row && row.parentid_all){
											$('#' + rootid + ' a.medical_single_entity_fee span').html(row.parentid_all)
										}
									}
								}
								_medicalPricePanel = _panel_change.html()
								private_method.bindBtnEvent()
							}
					    })
					}
				},
				
				medicalMedicalMangerPanelHtml:function(){
					var tepHtml = "<span><div class=\"t-list\">药品招标品种数: <a href=\"#\" class=\"drug_sum medical-indicate\" indicate=\"drug_from\"><span >0</span> </a> </div>	</span>" + 
							"<span><div class=\"t-list\">药品使用品种数: <a href=\"#\" class=\"drug_sum medical-indicate\" indicate=\"drug_sum\"><span >0</span> </a> <span>标准值：<font color=\"blue\">1200</font></span></div>	</span>" +
							"<span><div class=\"t-list\">抗菌药品使用品种数: <a href=\"#\" class=\"drug_anti medical-indicate\" indicate=\"drug_anti_sum\"><span >0</span> </a> <span>标准值：<font color=\"blue\">50</font></span></div>	</span>" +
							"<div class=\"t-list\"><a href=\"#\" class=\"drug_dept medical-indicate\" indicate=\"drug_count\">用药排名</a></div>" +
							"<div class=\"t-list\"><a href=\"#\" class=\"drug_percent medical-indicate\" indicate=\"drug_percent\">药占比</a></div>" +
							"<div class=\"t-list\"><a href=\"#\" class=\"raise_charge medical-indicate\" indicate=\"raise_charge\">药品加成率</a></div>" +
							"<div class=\"t-list\"><a href=\"#\" class=\"fee_over medical-indicate\" indicate=\"over_standered\">科室越权收费</a></div>" +
							"<div class=\"t-list\"><a href=\"#\" class=\"duplicate_charge medical-indicate\" indicate=\"duplicate_charge\">重复收费</a></div>"
					$('#' + rootid + ' .medical-panel-change').html(tepHtml)
				},
				
				medicalMedicalMangerPanel:function(){
					var _panel_change = $('#' + rootid + ' .medical-panel-change')
					_panel_change.empty()
					if(_medicalMedicalMangerPanel){
						
						_panel_change.html(_medicalMedicalMangerPanel)
						private_method.bindBtnEvent()
					}
					else{
						var _data = private_method.getDateValue()
						private_method.medicalMedicalMangerPanelHtml()
						ajaxServ.runAjax({
							url:_bizProto.rootPath + medicalMedicalMangerPart,
							data:{condition:_data, groupBy:'allDrug'},
							callback:function(data){
								if(data){
									if(data && data.rows[0]){
										var row = data.rows[0]
										if(row && row.drug_sum){
											var cnt = '<font color="green">' + row.drug_sum + '</font>'
											$('#' + rootid + ' a.drug_sum span').html(cnt)
											//$('#' + rootid + ' a.drug_from span').html(cnt)
											//$('#' + rootid + ' a.overlay-prescribe span').html('0')
										}
										if(row && row.drug_anti){
											var cnt = '<font color="green">' + row.drug_anti + '</font>'
											$('#' + rootid + ' a.drug_anti span').html(cnt)
											//$('#' + rootid + ' a.drug_from span').html(cnt)
											//$('#' + rootid + ' a.overlay-prescribe span').html('0')
										}
									}
								}
								_medicalMedicalMangerPanel = _panel_change.html()
								private_method.bindBtnEvent()
							}
					    })
					}
				},
				
				medicalPathwayPanelHtml:function(){
					var tepHtml = 
							"<div class=\"t-list\">临床路径完成率: <a href=\"#\" class=\"pathway-patient medical-indicate\" indicate=\"pathway-patient\"><span class=\"complete\">0</span> %</a> <span>标准：<font color=\"blue\">70%</font></span></div>" +
							"<div class=\"t-list\">临床路径入组率: <a href=\"#\" class=\"pathway-patient medical-indicate\"indicate=\"pathway-patient\"><span class=\"access\" >0</span> %</a> <span>标准：<font color=\"blue\">50%</font></span></div>"
					$('#' + rootid + ' .medical-panel-change').html(tepHtml)
				},
				
				medicalPathwayPanel:function(){
					var _data = private_method.getDateValue()
					var _panel_change = $('#' + rootid + ' .medical-panel-change')
					_panel_change.empty()
					if(_medicalPathwayPanel){
						
						_panel_change.html(_medicalPathwayPanel)
						private_method.bindBtnEvent()
					}
					else{
						private_method.medicalPathwayPanelHtml()
						ajaxServ.runAjax({
							url:_bizProto.rootPath + medicalUsePart,
							data:{condition:_data},
							callback:function(data){
								if(data){
									if(data.pathway_patient && data.pathway_patient.rows[0]){
										var row = data.pathway_patient.rows[0]
										if(row && row.completePer){
											var cnt = (row.completePer * 100).toFixed(2)
											if(cnt > 70){
												cnt = '<font color="green">' + cnt + '</font>'
											}else{
												cnt = '<font color="red">' + cnt + '</font>'
											}
											var completeSpan = $('#' + rootid + ' a.pathway-patient span.complete')
											completeSpan.html(cnt)
											cnt = (row.accessPer * 100).toFixed(2)
											if(cnt > 70){
												cnt = '<font color="green">' + cnt + '</font>'
											}else{
												cnt = '<font color="red">' + cnt + '</font>'
											}
											var accessSpan = $('#' + rootid + ' a.pathway-patient span.access')
											accessSpan.html(cnt)
										}
									}
									_medicalPathwayPanel = _panel_change.html()
									private_method.bindBtnEvent()
								}
							}
					    })
					}
				},
				
				medicalUsePanelHtml:function(){
					var tepHtml ="<div class=\"t-list\">门诊基本药物金额比例 :" +
							"<a href=\"#\" class=\"base-medical-outpatient medical-indicate\" indicate=\"base-medical-outpatient\"><span >00.00</span>%  </a>,标准: <span class=\"base-medical-outpatient-standard medical-standard\">00.00</span>%" +
							"</div>" +
							"<div class=\"t-list\">住院基本药物金额比例 :" +
							"<a href=\"#\" class=\"base-medical-inpatient medical-indicate\" indicate=\"base-medical-inpatient\"><span >00.00</span>%  </a>,标准: <span class=\"base-medical-inpatient-standard medical-standard\">00.00</span>%" +
							"</div>" +
							"<div class=\"t-list\">门诊抗菌药物使用率 : <a href=\"#\"  class=\"outpatient-anti-use medical-indicate\" indicate=\"outpatient-anti-use\"><span>00.00</span>% </a>,标准 <span class=\"outpatient-anti-use-standard medical-standard\">00.00</span>%</div>" +
							"<div class=\"t-list\">住院抗菌药物使用率 :" + 
							"<a href=\"#\" class=\"inpatient-anti-use medical-indicate\" indicate=\"inpatient-anti-use\"><span >00.00</span>% </a>,标准 <span class=\"inpatient-anti-use-standard medical-standard\">00.00</span>%</div>" +
							"<div class=\"t-list\">急诊抗菌药物使用率 :" +
							"<a href=\"#\" class=\"outemrpatient-anti-use medical-indicate\" indicate=\"outemrpatient-anti-use\"><span >00.00</span>% </a>,标准 <span class=\"outemrpatient-anti-use-standard medical-standard\">00.00</span>%</div>" +
							"<span><div class=\"t-list\">出院患者抗菌药物使用强度(DDD): <a href=\"#\" class=\"inpatient-ddd medical-indicate\" indicate=\"inpatient-ddd\"><span>00.00</span> </a> 标准 <span class=\"inpatient-ddd-standard medical-standard\">00.00</span></div></span>" 
							
					$('#' + rootid + ' .medical-panel-change').html(tepHtml)
				},
				
				medicalUsePanel:function(){
					var _data = private_method.getDateValue()
					var _panel_change = $('#' + rootid + ' .medical-panel-change')
					_panel_change.empty()
					if(_medicalUsePanel){
						
						_panel_change.html(_medicalUsePanel)
						private_method.bindBtnEvent()
					}
					else{
						private_method.medicalUsePanelHtml()
						ajaxServ.runAjax({
							url:_bizProto.rootPath + medicalUsePart,
							data:{condition:_data},
							callback:function(data){
								if(data){
									
									if(data.anti_dose){
										var row = data.anti_dose.rows[0]
										if(row && row.anti_ddd){
											var ddd = row.anti_ddd.toFixed(2)
											var standard = row.amount_percent_standard
											if(!ddd){
												ddd = 0
											}
											if(!standard){
												standard = 0
											}
											if(ddd>standard){
												ddd = '<font color="red">' + ddd + '</font>'
											}else{
												ddd = '<font color="green">' + ddd + '</font>'
											}
											
											$('#' + rootid + ' a.inpatient-ddd span').html(ddd)
											$('#' + rootid + ' span.inpatient-ddd-standard').html('<font color="blue">' +standard+'</font>')
										}
									}
									
									if(data.base_medical && data.base_medical.rows){
										var da,bda,d
										$.each(data.base_medical.rows,function(index,row){
											var p = row.amount_percent
											var s = row.amount_percent_standard
											if(!p){
												p = 0
											}
											if(!s){
												s = 0
											}
											if(p>s){
												p = '<font color="green">' + p + '</font>'
											}else{
												p = '<font color="red">' + p + '</font>'
											}
											
											s = '<font color="blue">' +s+'</font>'
											if(row.patient_type==1){
												$('#' + rootid + ' a.base-medical-outpatient span').html(p)
												var tpTest = $('#' + rootid + ' span.base-medical-outpatient-standard')
												tpTest.html(s)
											}else{
												$('#' + rootid + ' a.base-medical-inpatient span').html(p)
												var tpTest = $('#' + rootid + ' span.base-medical-inpatient-standard')
												tpTest.html(s)
											}
											
											
										})									
										
									}
									
									if(data.anti_medical && data.anti_medical.rows){
										$.each(data.anti_medical.rows,function(index,row){
											
											var p = row.anti_percent
											var s = row.amount_percent_standard
											if(!p){
												p = 0
											}
											if(!s){
												s = 0
											}
											
											if(p<=s){
												p = '<font color="green">' + p + '</font>'
											}else{
												p = '<font color="red">' + p + '</font>'
											}
											
											s = '<font color="blue">' +s+'</font>'
											if(row.patient_type==1){
												$('#' + rootid + ' a.outpatient-anti-use span').html(p)
												$('#' + rootid + ' span.outpatient-anti-use-standard').html(s)
											}else if(row.patient_type==2){
												$('#' + rootid + ' a.inpatient-anti-use span').html(p)
												$('#' + rootid + ' span.inpatient-anti-use-standard').html(s)
											}else{
												$('#' + rootid + ' a.outemrpatient-anti-use span').html(p)
												$('#' + rootid + ' span.outemrpatient-anti-use-standard').html(s)
											}
										})
										
									}
									_medicalUsePanel = _panel_change.html()
									private_method.bindBtnEvent()
								}
							}
					    })
					}
				},
				
				medicalCheckPanelHtml:function(){
					var tepHtml ="<div class=\"t-list\">大型检查阳性率: <a href=\"#\" class=\"large-positive medical-indicate\" indicate=\"large-positive\"><span>0</span> %</a> 标准 <span class=\"large-positive-standard medical-standard\"><font color=\"blue\">70.00</font></span> %</div>"
					+ "<div class=\"t-list\">同一人开单执行: <a href=\"#\" class=\"billing_by_one medical-indicate\" indicate=\"billing_by_one\"><span>0</span> %</a></div>"
					+ "<div class=\"t-list\">同一人多检查: <a href=\"#\" class=\"multicheck_by_one medical-indicate\" indicate=\"multicheck_by_one\"><span>0</span> %</a></div>"
					$('#' + rootid + ' .medical-panel-change').html(tepHtml)
				},
				
				medicalCheckPanel:function(){
					var _data = private_method.getDateValue()
					var _panel_change = $('#' + rootid + ' .medical-panel-change')
					_panel_change.empty()
					if(_medicalCheckPanel){
						
						_panel_change.html(_medicalCheckPanel)
						private_method.bindBtnEvent()
					}
					else{
						private_method.medicalCheckPanelHtml()
						ajaxServ.runAjax({
							url:_bizProto.rootPath + medicalCheckPart,
							data:{condition:_data},
							callback:function(data){
								if(data){
									//查询大型阳性检查
									if(data.large_positive && data.large_positive.rows[0]){
										var row = data.large_positive.rows[0]
										var p = row.ratio_positive
										var s = row.amount_percent_standard
											if(p==null||s==null){
												if(p==null){
													p=0;
												}
												if(s==null){
													s=0;
												}
											}
											if(p>s){
												p = '<font color="green">' + p + '</font>'
												$('#' + rootid + ' a.large-positive span').html(p)
												
											}else{
												p = '<font color="green">' + p + '</font>'
												$('#' + rootid + ' a.large-positive span').html(p)
											}
											
											s = '<font color="blue">' +s+'</font>'
											$('#' + rootid + ' span.large-positive-standard').html(s)
										
									}
									_medicalCheckPanel = _panel_change.html()
									private_method.bindBtnEvent()
								}
							}
					    })
					}
				},
				
				destroyCharts:function(charts){
					if(charts){
						for(var i=0;i<charts.length;i++){
							if(!charts[i]){
								charts.splice(i,1)
							}
						}
					}
					charts = null
				},
				
				initChart:function(data){
					private_method.initDutiesChart(data.duties)
					private_method.initMedicalChart(data.medical)
					private_method.initSatisfactionChart(data.satisfaction)
					private_method.initSupplyChart(data.supply)
				},
				
				initDutiesChart:function(data){
					
					console.info("initDutiesChar init...");
					Highcharts.getOptions().colors = Highcharts.map(_colors, function (color) {
				        return {
				            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
				            stops: [
				                [0, color],
				                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
				            ]
				        };
				    });
					var _container =$('#'+rootid +' #container-duties')
					$(_container).empty()
					var _param ={
						title: {
				            text: false
				        },
						series: [{
							allowPointSelect:true,
				            type: 'pie',
				            name: '所占比例',
				            data: data,
				            events:{click:private_method.chartClickDuties}
				        }]
					}
					
					_param =$.extend({},chartConfig,_param)
					$(_container).highcharts(_param);
				},
				
				initMedicalChart:function(data){
					
					console.info("initMedicalChart init...");
					Highcharts.getOptions().colors = Highcharts.map(_colors, function (color) {
				        return {
				            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
				            stops: [
				                [0, color],
				                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
				            ]
				        };
				    });
					var _container =$('#'+rootid + ' #container-medical')
					$(_container).empty()
					var _param ={
						title: {
				            text: false
				        },
						series: [{
							allowPointSelect:true,
				            type: 'pie',
				            name: '所占比例',
				            data: data,
				            events:{click:private_method.chartClickMedical}
				        }]
					}
					
					_param =$.extend({},chartConfig,_param)
					$(_container).highcharts(_param);
				},
			
				//初始化全部业务图表
				initSatisfactionChart:function(data){
					
					console.info("initSatisfactionChart init...");
					Highcharts.getOptions().colors = Highcharts.map(_colors, function (color) {
				        return {
				            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
				            stops: [
				                [0, color],
				                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
				            ]
				        };
				    });
					var _container =$('#'+rootid + ' #container-satisfaction')
					$(_container).empty()
					var _param ={
						title: {
				            text: false
				        },
						series: [{
							allowPointSelect:true,
				            type: 'pie',
				            name: '所占比例',
				            data: data,
				            events:{click:private_method.chartClickSatisfaction}
				        }]
					}
					
					_param =$.extend({},chartConfig,_param)
					$(_container).highcharts(_param);
					
				},
				
				//初始化全部业务图表
				initSupplyChart:function(data){
					
					console.info("initSupplyChart init...");
					Highcharts.getOptions().colors = Highcharts.map(_colors, function (color) {
				        return {
				            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
				            stops: [
				                [0, color],
				                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
				            ]
				        };
				    });
					var _container =$('#'+rootid + ' #container-supply')
					$(_container).empty()
					var _param ={
						title: {
				            text: false
				        },
						series: [{
							allowPointSelect:true,
				            type: 'pie',
				            name: '所占比例',
				            data: data,
				            events:{click:private_method.chartClickSupply}
				        }]
					}
					
					_param =$.extend({},chartConfig,_param)
					$(_container).highcharts(_param);
					
				},
				getDateValue:function(){
					
					var _form = $('#'+ rootid +' form.condition-form ')
					var ret = formServ.getDataObj({
						rootId:rootid,
						form : $(_form)
					});
					return ret
				},

			
				chartClick:function(e){
					console.info("chartClick init...");
					//var _series =this.getSelectedSeries();
//					alert('series: ' +e.point.name +' selected. value: ' + e.point.y);
					var _param={}
					var _config
					if(e.point.issue){
						switch(e.point.issue){
							case 'duties':
								_config=sysmanMain.getModuConf('duties:dutiesInquiry');								
								break;
							case 'medical':
								_config=sysmanMain.getModuConf('medical:recipel');					
								break;							
							default:
								break;
						}
					}					
					
					if(e.point.name){
						switch(e.point.name){
							case '待处理':
							if(_config)
								private_method.openTab(_config);
							break;
							case '处理中':
							
							default:
								break;
						}
					}
					
				},
				chartClickDuties:function(e){
					var _param={}
					var _config=sysmanMain.getModuConf('duties:dutiesInquiry');									
					console.info("chartClickDuties function...");
					if(e.point.name){
						switch(e.point.name){
							case '待处理':
							if(_config)
								private_method.openTab(_config);
							break;
							case '处理中':								
								
								dutiesInquiryInfo.pageOpen({queryModule:'dutiesInquiry',queryMethod:'getUserManagedTaskDomain'});
								break;
							case '已处理':
								dutiesInquiryInfo.pageOpen({queryModule:'dutiesInquiry',queryMethod:'getFinishedTaskListDomain'});
								break;
							default:
								break;
						}
					}
				},
				
				chartClickMedical:function(e){
					console.info("chartClickMedical function...");
					var _param={}
					var _config=sysmanMain.getModuConf('medical:recipel');									
					
					if(e.point.name){
						switch(e.point.name){
							case '待处理':
							if(_config)
								private_method.openTab(_config);
							break;
							case '处理中':								
								
								medicalInfo.pageOpen({queryModule:'medicalRecipel',queryMethod:'getUserManagedTaskDomain'});
								break;
							case '已处理':
								medicalInfo.pageOpen({queryModule:'medicalRecipel',queryMethod:'getFinishedTaskListDomain'});
								break;
							default:
								break;
						}
					}
				},
				
				chartClickSatisfaction:function(e){
					var _param={}
					var _config=sysmanMain.getModuConf('satisfaction:statisfactionInquiry');									
					console.info("chartClickSatisfaction function...");
					if(e.point.name){
						switch(e.point.name){
							case '待处理':
							if(_config)
								private_method.openTab(_config);
							break;
							case '处理中':								
								
								satisfactionInfo.pageOpen({queryModule:'satisRank',queryMethod:'getUserManagedTaskDomain'});
								break;
							case '已处理':
								satisfactionInfo.pageOpen({queryModule:'satisRank',queryMethod:'getFinishedTaskListDomain'});
								break;
							default:
								break;
						}
					}
				},
				chartClickSupply:function(e){
					var _param={}
					var _config=sysmanMain.getModuConf('supply:supplyInquiry');									
					console.info("chartClickSupply function...");
					if(e.point.name){
						switch(e.point.name){
							case '待处理':
							if(_config)
								private_method.openTab(_config);
							break;
							case '处理中':								
								
								supplyInquiry.pageOpen({queryModule:'supplyInquiry',queryMethod:'getUserManagedTaskDomain'});
								break;
							case '已处理':
								supplyInquiry.pageOpen({queryModule:'supplyInquiry',queryMethod:'getFinishedTaskListDomain'});
								break;
							default:
								break;
						}
					}
				},
				openTab:function(_config){
					var _url,_text,rootPath
					
					rootPath = '/'+ sysmanMain.getRootPath();
					
					if(_config.pageURL && _config.name){
						_url = _config.pageURL;
						_text = _config.name?$.trim(_config.name):null
					
						if(_text && _text.length>0){
							//保存当前tab页							
							var _options = {
								target : 'centerTabs',
								title : _text,
								tabUrl : rootPath+_url,
								tools : []
							};
							if (_url) {
			//					tabServ.addFrameTab(_options);
								tabServ.addHrefTab(_options)
							}
						}
					}
				}
			}
			
			return public_method;

		});